class @AdminResponseListingModel extends ListingModel
    @ListingUrl:''

    initialize: ->
        if AdminResponseListingModel.ListingUrl.length==0
            AdminResponseListingModel.ListingUrl = SiteMap.Admin.Responses.Listing

    defaults:
        Size: 10
        Page: 1
        Direction: 0
        Responses: []
        Column: "UserEmail"
        Filter:
            UserId: ''
            BookId: ''
            UserEmail: ''
            BookTitle: ''
            DateFrom: ''
            DateTo: ''

    url: ->
        url = AdminResponseListingModel.ListingUrl
        url += "?page=" + @attributes.Page
        url += "&size=" + @attributes.Size
        url += "&Column=" + @attributes.Column
        url += "&Direction=" + @attributes.Direction
        url += "&Filter.UserId=" + @attributes.Filter.UserId
        url += "&Filter.BookId=" + @attributes.Filter.BookId
        url += "&Filter.UserEmail=" + @attributes.Filter.UserEmail
        url += "&Filter.BookTitle=" + @attributes.Filter.BookTitle
        url += "&Filter.DateFrom=" + @attributes.Filter.DateFrom
        url += "&Filter.DateTo=" + @attributes.Filter.DateTo
        SiteMap.Admin.Responses.Listing = encodeURI(url)
        return SiteMap.Admin.Responses.Listing

    parse: (response) ->
        attrs = {
            Size: response.Size
            Page: response.Page
            TotalPages: response.TotalPages
            Column: response.Column
            Direction: response.Direction
            Filter: @attributes.Filter
        }

        attrs.Responses = response.Responses
        if response.Filter.UserId?
            attrs.Filter.UserId = response.Filter.UserId
        if response.Filter.BookId?
            attrs.Filter.BookId = response.Filter.BookId
        if response.Filter.UserEmail?
            attrs.Filter.UserEmail = response.Filter.UserEmail
        if response.Filter.BookTitle?
            attrs.Filter.BookTitle = response.Filter.BookTitle
        if response.Filter.DateFromAsString?
            attrs.Filter.DateFrom = response.Filter.DateFromAsString
        if response.Filter.DateToAsString?
            attrs.Filter.DateTo = response.Filter.DateToAsString

        return attrs